<?php namespace Siyuanliu\Filmcms\Updates;

use Schema;
use October\Rain\Database\Schema\Blueprint;
use October\Rain\Database\Updates\Migration;

class CreateCategoriesTable extends Migration
{
    public function up()
    {
        Schema::create('siyuanliu_filmcms_categories', function(Blueprint $table) {
            $table->engine = 'InnoDB';
            $table->increments('id');
            $table->string('title',255);
            $table->string('description',255);
            $table->integer('pid');
            $table->integer('sort')->nullable();
            $table->tinyInteger('is_show');
            $table->timestamps();
        });

        Schema::create('siyuanliu_filmcms_films_categories', function($table)
        {
            $table->engine = 'InnoDB';
            $table->integer('film_id')->unsigned();
            $table->integer('category_id')->unsigned();
            $table->primary(['film_id', 'category_id']);
        });
    }


    public function down()
    {
        Schema::dropIfExists('siyuanliu_filmcms_categories');
        Schema::dropIfExists('siyuanliu_filmcms_films_categories');

    }
}
